﻿using System;
using System.Windows;
using System.Windows.Forms;

namespace PluginMediatorSample.Classes
{
    class B : A
    {
        public B()
        {
            Mediator.Register<Test2Delegate>(this, "message", Test2);
            MessageBox.Show(string.Format("+ {0}", typeof(B).Name));
        }

        private static void Test2(SomeData2 data)
        {
            MessageBox.Show(string.Format("{0} : {1}", typeof(B).Name, data.Value));
        }

        /// <summary>
        /// Finalizer to show that the ViewModel is garbage collected
        /// </summary>
        ~B()
        {
            Mediator.Unregister<Test2Delegate>(this, "message", Test2);
            MessageBox.Show(string.Format("- {0}", typeof(B).Name));
        }
    }
}